package cn.shop.dys.constant;

import android.os.Environment;
import android.view.View;
import android.view.ViewGroup;


public class Constant {
	/**
	 ******************************************* 参数设置信息开始 ******************************************
	 */


	// SDCard路径
	public static final String SD_PATH = Environment
			.getExternalStorageDirectory().getAbsolutePath();

	// 图片存储路径
	public static final String BASE_PATH = SD_PATH + "/iTau/dieyi/";

	// 缓存图片路径
	public static final String BASE_IMAGE_CACHE = BASE_PATH + "cache/images/";

	// 需要分享的图片
	public static final String SHARE_FILE = BASE_PATH + "QrShareImage.png";



	// 屏幕高度
	public static int SCREEN_HEIGHT = 800;

	// 屏幕宽度
	public static int SCREEN_WIDTH = 480;

	// 屏幕密度
	public static float SCREEN_DENSITY = 1.5f;

public static  void setViewHeightAndWidth(View v,Integer height,Integer width){
	ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
	if (height != null) {

		layoutParams.height=height;
	}
	if (width != null) {

		layoutParams.width=width;
	}
	v.setLayoutParams(layoutParams);

}

	/**
	 ******************************************* 参数设置信息结束 ******************************************
	 */


	/**
	 ******************************************* 分类 ******************************************
	 */



//	// public static String  preUrl= "http://10.0.2.2:8080/market";
//	// public static String HOST = "http://10.0.2.2:8080/market";
//
//
	//public static final String preUrl= "http://192.168.175.2:8080/market";
	public static final String url = CommonConstant.HOST + "/category";
	public static final String LOGIN_URL = CommonConstant.HOST + "/login";
	public static final String REGISTER_URL = CommonConstant.HOST + "/register";

	//    public static final String key_userid = "userid";
	public static final String USERNAME = "username";
	public static final String PASSWORD = "password";
	public static final String KEY_NAME = "name";
	public static final String KEY_ID = "cId";

	public static final String HOST = "http://192.168.175.2:8080/market";
	public static String getUrl(String uri) {
		if (uri.startsWith("http://")) {
			if (uri.startsWith("http://10.0.2.2:")) {

				uri.replace("http://10.0.2.2", CommonConstant.HOST.substring(0,CommonConstant.HOST.lastIndexOf(":")));
			}

		} else {
			uri = HOST + uri;

		}
		return uri;
	}


	public static final String ERROR_CODE = "error_code";

	//用户名不存在或密码错误
	public static final String ERROR_CODE_NOT_EXIST_USER = "1530";
	//请求头没有userid错误码
	public static final String ERROR_CODE_NO_USERID_ON_REQUEST_HEAD = "1531";
	//该用户名已经被注册过了
	public static final String ERROR_CODE_USERNAME_BEEN_REGISTERED = "1532";
	//没有登录或则需要重新登录
	public static final String ERROR_CODE_UNLOGIN = "1533";
	//请求参数错误或缺失
	public static final String ERROR_CODE_REQUEST_PARAMETER_ERROR = "1534";
	//当前商品已经添加过收藏
	public static final String ERROR_CODE_HAD_ADD_FAVORITES = "1535";
	//商品已经添加收藏失败
	public static final String ERROR_CODE_FAILER_ADD_FAVORITES = "1536";

	//取消订单失败
	public static final String ERROR_CODE_FAILER_CANCLE_ORDER = "1537";

	//没有该订单详情
	public static final String ERROR_CODE_NO_ORDER_DETAIL = "1538";
}
